#include "ScenePrecompiled.hxx"
#include "InternalMeshContextImpl.hxx"
#include "InternalSceneStaticImpl.hxx"
#include "InternalSceneConv.hxx"
#include "InternalSceneImpl.hxx"

Eifersucht::MeshContext::_Internal_impl::_Internal_impl( _In_ Eifersucht::MeshContextPtr _pRef ) : 
	_m_pRef(_pRef)
{
}

Eifersucht::MeshContext::_Internal_impl::~_Internal_impl()
{
}

bool  Eifersucht::MeshContext::_Internal_impl::_Triangulate_mesh()
{
	if ( !_m_pAttr || !_m_pRef ) return false; // Smth is wrong around here 
	else if ( !_m_pAttr->IsTriangleMesh() ) // Check whether the triangulation succeeded. 
	{
		PrintToDebugWindowOnly8( // Some printout for debug ver
			"Eifersucht. InternalMeshCtxImpl. "
			"Triangulating the mesh." 
			);

		// Create geometry converter
		Fbx::GeometryConverter lConv( Eifersucht::Scene::_Internal_static_impl::_s_pManager );
		// Traverse the scene to try to reach the scene object pointer 
		AutoDebugVariable(bResult) lConv.Triangulate( _m_pRef->m_pRef->GetParentScene()->m_pImpl->_m_pScene, true );
	}

	// Check whether the triangulation succeeded, 
	return _m_pAttr->IsTriangleMesh(); // once again to be sure.
}

void Eifersucht::MeshContext::_Internal_impl::_Cpy_name()
{
	AutoDebugVariable(szName) _m_pAttr->GetName(); // Weird
}

void Eifersucht::MeshContext::_Internal_impl::_Cpy_all()
{
	_Cpy_name();
	_Cpy_geom();
	_Cpy_link();
}